package com.fzhucc.modules.pms.repository;

import com.fzhucc.modules.pms.domain.Project;
import com.fzhucc.modules.pms.domain.ProjectLargeSmall;
import com.fzhucc.modules.pms.domain.ProjectSmall;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import javax.validation.constraints.NotNull;

/**
 * @author Woolsen
 */
public interface ProjectLargeSmallRepository extends JpaRepository<ProjectLargeSmall, String>, JpaSpecificationExecutor<ProjectLargeSmall> {

    @Query(nativeQuery = true, value = "SELECT * FROM pms_project where level=:level and (del_flag=0 or del_flag is null) order by sort desc")
    Page<ProjectLargeSmall> queryAllProNameWithOutDetails(@NotNull Integer level, Pageable pageable);

    @Query(nativeQuery = true, value = "SELECT * FROM pms_project where level=:level and org_area=:orgArea and (del_flag=0 or del_flag is null) order by sort desc")
    Page<ProjectLargeSmall> queryAllProNameWithOutDetailsByOrgArea(@NotNull Integer level,String orgArea, Pageable pageable);

}